<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Cart extends Model
{
    protected $fillable=[
        'goods_id','product_id','user_id','num','price','sum'
    ];
    //购物车模型和商品模型和货品模型是多对一的关系,在购物车对象模型中写两个反向模型关联的方法
    public function goods(){
        return $this->belongsTo(Goods::class,'goods_id');
    }
    public function product(){
        return $this->belongsTo(Product::class,'product_id');
    }
}
